package com.bitsfromspace.ubertorrent.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


/**
 * Author: chris.oudeman
 * Since: Jan 6, 2011
 */
public class Sha1HashUtils {

	/**
	 * Calculates the 20 bytes SHA1 hash from the data provided.
	 */
	public static byte[] calculateHash(byte[] in) {

		try {
			MessageDigest digest = MessageDigest.getInstance("SHA-1");
			digest.update(in);
			return digest.digest();
		} catch (NoSuchAlgorithmException nsea) {//SHA1 MUST be in JDK1.4+
			throw new RuntimeException(nsea);
		}
	}

}


